#! /bin/sh

name=readline
_patch=13
version=8.2p${_patch}
revision=1
tarball_url="https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz"
tarball_blake2b="7974322b9c092a756a79e537df08e8532f8e0fcb598f77732e28287c33ebec9e9837ed88b43334c310892d56a871b423903f0f564def2fbe700a1004f2ae7b18"
source_allow_network="yes"
hostdeps="gcc pkg-config"
deps="core-libs ncurses"

prepare() {
    for p in $(seq -w 0${_patch}); do
        curl -L https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-$p | patch -p0
    done

    autotools_recursive_regen
}

configure() {
    autotools_configure \
        --enable-multibyte \
        --with-curses
}

build() {
    make SHLIB_LIBS="-lncursesw -ltinfow" -j${parallelism}
}

package() {
    make install DESTDIR="${dest_dir}"

    post_package_strip
}
